<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "taoke_order_info".
 *
 * @property integer $_id
 * @property string $id
 * @property string $goodsid
 * @property string $title
 * @property string $d_title
 * @property string $pic
 * @property string $cid
 * @property string $org_price
 * @property integer $price
 * @property string $istmall
 * @property integer $sales_num
 * @property string $dsr
 * @property string $sellerid
 * @property string $commission
 * @property string $commission_jihua
 * @property string $commission_queqiao
 * @property string $jihua_link
 * @property string $que_siteid
 * @property string $jihua_shenhe
 * @property string $introduce
 * @property string $quan_id
 * @property string $quan_price
 * @property string $quan_time
 * @property string $quan_surplus
 * @property string $quan_receive
 * @property string $quan_condition
 * @property string $quan_m_link
 * @property string $quan_link
 * @property string $ts
 * @property integer $use_cnt
 * @property integer $sort
 * @property integer $status
 * @property string $opty
 */
class TaokeOrderInfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'taoke_order_info';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['price', 'sales_num', 'use_cnt', 'sort', 'status'], 'integer'],
            [['ts'], 'safe'],
            [['id', 'goodsid', 'cid', 'org_price', 'istmall', 'dsr', 'sellerid', 'commission', 'commission_jihua', 'commission_queqiao', 'que_siteid', 'jihua_shenhe', 'quan_price', 'quan_time', 'quan_surplus', 'quan_receive', 'quan_condition'], 'string', 'max' => 64],
            [['title', 'd_title', 'quan_id'], 'string', 'max' => 128],
            [['pic', 'jihua_link', 'introduce', 'quan_m_link', 'quan_link'], 'string', 'max' => 255],
            [['opty'], 'string', 'max' => 11],
            [['goodsid', 'sellerid'], 'unique', 'targetAttribute' => ['goodsid', 'sellerid'], 'message' => 'The combination of Goodsid and Sellerid has already been taken.'],
        ];
    }

    public function getOpty($opty){

        $optys = array( 'hot' => '畅销榜', 'new' => '最新','bao' => '包邮','hai'=>'品牌','free'=>'免费');

        if($opty==""){
            return "无";    
        }
        return $optys[$opty.''];
    }

    public function getCid($cid){

        $cids = array( '1' => '女装', '9' => '男装'
            ,'10'=>'内衣'
            ,'2'=>'母婴'
            ,'3'=>'化妆品'
            ,'4'=>'居家'
            ,'5'=>'鞋包配饰'
            ,'6'=>'美食'
            ,'7'=>'文体车品'
            ,'8'=>'数码家电'

            );


        return $cids[$cid.''];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            '_id' => 'Id',
            'id' => 'ID',
            'goodsid' => '淘宝商品id',
            'title' => '商品名字',
            'd_title' => '商品介绍',
            'pic' => '商品图片',
            'cid' => '商品类别',
            'org_price' => '商品原价',
            'price' => '商品价格',
            'istmall' => '是否天猫',
            'sales_num' => '销量',
            'dsr' => '商品描述分',
            'sellerid' => '卖家ID',
            'commission' => '计划(通用)佣金比例',
            'commission_jihua' => '计划(通用)佣金比例',
            'commission_queqiao' => '高佣鹊桥佣金比例',
            'jihua_link' => '计划链接',
            'que_siteid' => 'Que Siteid',
            'jihua_shenhe' => '计划审核状态',
            'introduce' => '商品文案',
            'quan_id' => '优惠券ID',
            'quan_price' => '优惠券金额',
            'quan_time' => '优惠券结束时间',
            'quan_surplus' => '优惠券剩余数量',
            'quan_receive' => '已领券数量',
            'quan_condition' => '优惠券使用条件',
            'quan_m_link' => '手机券短接',
            'quan_link' => '手机券链接',
            'ts' => '时间',
            'use_cnt' => '个数',
            'sort' => '排序越大越前',
            'status' => '0 上线 1下线',
            'opty' => '类型',
        ];
    }
}
